﻿@model YQBlog.Models.NoteModel
@using res = Resource.Views.Home.Home;
@{
    YQBlog.General.GeneralConfigInfo ci = ViewBag.CI as YQBlog.General.GeneralConfigInfo;
    ViewBag.Title = res.Note;
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<div class="web_path">@res.Path：@Html.ActionLink(res.HomePage, "Index", "Home") \ @Html.Raw(ViewBag.WebPath)</div>
<div class="page_wrap">
    <h2>@res.Note</h2>
    <div class="pager notepage mt10"></div>
    @if ((ViewData["NoteList"] as IEnumerable<YQBlog.Models.blog_varticle>).Count() > 0)
    {  
        <div class="commentlist">
            <ul>
            @foreach (var item in ViewData["NoteList"] as IEnumerable<YQBlog.Models.blog_varticle>)
            {
                <li id="@item.id" f="@item.orderid" u="@item.username.Trim()" v="@item.content" class="clearfix">
                    <p>
                    <a href="#f_@(item.orderid)" id="f_@(item.orderid)" class="replylayer" >#@(item.orderid)@res.Floor</a>
                    <span class="replayuser">
                    @if (item.userid == 1)
                    {
                        <a href="@Html.YQUrl("/u/"+System.Web.HttpUtility.UrlEncode(item.username.Trim(), System.Text.Encoding.UTF8))">@item.username.Trim()</a>
                    }
                    else
                    {
                        @item.username.Trim()
                    }
                    </span>
                    @Html.GetTime(item.createdate)
                    </p>
                    <div class="replyavatar">
                        <img onerror="this.onerror=null;this.src='/Content/image/defaultPhoto.png';" src="/Content/Avatar/upload/avatars/@(item.username.Trim())/small.jpg"/>
                    </div>
                    <div class="replycontent">@Html.Raw(item.content)</div>
                    <div class="replyoperate">
                    @if (item.userid==1 && item.username.Trim() == User.Identity.Name)
                    {
                        <a href="###" class="reply-update" v="@item.id">@res.Modify</a> 
                        <a href="###" class="reply-del" v="@item.id">@res.Delete</a>
                    }
                    <a href="###" class="post-quote" v="@item.id">@res.Quote</a> 
                    <a href="###" class="post-re" v="@item.id">@res.Reply</a>
                    </div>
                    </li>
            }
            </ul>
        </div>
    }
    <div class="pager notepage"></div>
    <div id="post" class="mt10">
    @if (ci.UserPermission==1 && string.IsNullOrWhiteSpace(Model.UserName))
    { 
         <div>@res.MustLogInForNote, @res.Please @Html.ActionLink(res.SignIn, "LogOn", "Account") @res.Or @Html.ActionLink(res.Register, "Register", "Account")</div> 
    }
    else
    {
        using (Html.BeginForm("Note", "Home", FormMethod.Post, new { id = "myform" }))
        {                                                                                                                                                                                                                                                                                                                                                                                                                            
        <div id="commentform">
        <div id="insertCode">
        @res.ProLang：
        <select id="selCodeType">
            <option value="c#">C#</option>
            <option value="js">JavaScript</option>
            <option value="html">HTML</option>
            <option value="css">CSS</option>
            <option value="php">PHP</option>
            <option value="pl">Perl</option>
            <option value="py">Python</option>
            <option value="rb">Ruby</option>
            <option value="java">Java</option>
            <option value="vb">ASP/VB</option>
            <option value="cpp">C/C++</option>
            <option value="sql">SQL</option>
            <option value="xml">XML</option>
            <option value="as3">AS3</option>
            <option value="shell">Shell</option>
        </select>
        <br/>
        @res.Code：
        <textarea style="width:350px;height:200px;" id="txtCode"></textarea>
        <input type="button" onclick="InsertCode('Content')" value="@res.Submit" id="btnInsertCode"/>
        <a href="###" onclick="Hide('insertCode')">@res.Close</a>
        </div>

        <fieldset>
            <legend> @res.AddNote </legend>
            @Html.HiddenFor(m => m.ReplyId)
            @Html.HiddenFor(m => m.CateId)
            <div class="editor-label">
                @Html.LabelFor(m => m.UserName)
            </div>
            <div class="editor-field">
                @if (string.IsNullOrWhiteSpace(Model.UserName))
                {
                    @Html.TextBoxFor(m => m.UserName, new { style = "width: 200px;" })
                }
                else
                {
                   @Html.TextBoxFor(m => m.UserName, new { style = "width: 200px;border:#fff", ReadOnly = "readonly" })
                }
                @Html.ValidationMessageFor(m => m.UserName)
            </div>

            <div class="editor-label">
                @Html.LabelFor(m => m.Email)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.Email)
                @Html.ValidationMessageFor(m => m.Email)
            </div>

            <div class="editor-label">
                @Html.LabelFor(m => m.Url)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.Url)
                @Html.ValidationMessageFor(m => m.Url)
            </div>

            <div class="editor-label">
                @Html.LabelFor(m => m.Content)
            </div>
            <div style="width: 600px" class="editor_ubb">
              <div> 
              <a onclick="View('insertCode')" class="tb_code" href="javascript:;">Code</a>
              <a onclick="seditor_insertunit('Content', '[url=###]', '[/url]')" class="tb_link" href="javascript:;">Link</a>
              <a onclick="seditor_insertunit('Content', '[img]', '[/img]')" class="tb_img" href="javascript:;">Image</a>
              <a onclick="seditor_insertunit('Content', '[b]', '[/b]')" class="tb_bold" href="javascript:;">B</a>
              </div>
            </div>
            <div class="editor-field clstxtarea">
                @Html.TextAreaFor(model => model.Content, new { style = "width: 600px; height: 260px", id = "Content" })
                @Html.ValidationMessageFor(m => m.Content)
            </div>
            <div class="validation-code">
                <div class="editor-label">
                    @Html.LabelFor(m => m.ValidationCode)
                </div>
                <div class="editor-field validation clearfix">
                    @Html.TextBoxFor(m => m.ValidationCode, new { style = "width: 60px;height:20px;margin-top:7px;" })
                    <img src="/validateCode.ashx?n=4" class="validateImg" title="@res.ChangeValidationCode"/>
                    <span class="validateCodeTip">@res.ValidationCodeError</span>
                </div>
            </div>
            <p>
                <input type="submit" value="@res.Submit" id="BtnSubmit"/>
            </p>
        </fieldset>
    </div>
        }
    } 
    </div> 
</div>

<div id="sidebar">
</div>
@section Js{
<script src="@Url.Content("~/Scripts/jquery.pager.js")" type="text/javascript"></script>
<script type="text/javascript">
    var pageNo = @ViewBag.PageNo;
    var pageCount = @ViewBag.PageCount;
    var cid=@ViewBag.CateId;
    var url="@ViewBag.CurrentUrl";
    PageClick = function (no) {
        url=no>1?url+"?p=" + no:url;
        window.location = url;
    }
    $(function () {
        if (pageCount == 0) { $(".pager").hide() }
        $(".pager").pager({ pagenumber: pageNo, pagecount: pageCount, buttonClickCallback: PageClick });

        if (@(ci.IfValidateCode)==1) {
            $('.validation-code').show();
        }
        $("#BtnSubmit").click(function () {
            $.post("/Home/ValidationCodeJudge/", { code:$('#ValidationCode').val() , rn: Math.random() }, function (re) {
                if(re==1)
                {$("#myform").submit();}
                else
                {$('.validateCodeTip').show();}
            })
            return false;
        });
    });
</script>
}